package cn.wzvtc.soft14.function;

import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.common.BitMatrix;
import com.sun.javafx.collections.MappingChange;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by asus on 2016/6/24.
 */
public class QRcode {
    public void test1() throws Exception{
        String content = "www.baidu.com";
        String path = "d://";
        MultiFormatWriter multiFormatWriter = new MultiFormatWriter();//Zxing是Google提供的关于条码
        Map hints = new HashMap();
        hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
        BitMatrix bitMatrix = multiFormatWriter.encode(content, BarcodeFormat.QR_CODE, 400, 400,hints);//这里是照片的大小
        File file1 = new File(path,"my.jpg");
        MatrixToImageWriter.writeToFile(bitMatrix, "jpg", file1);
        System.out.println("执行完毕");
    }
}
